home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / sound / sndplaydoublebuffer / _headers / readresource.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.3 KB  |  83 lines

  1. /*
  2.     File:        ReadResource.h
  3.  
  4.     Contains:    Header for routines demonstrating how to read resource files without
  5.                 using the Resource Manager.
  6.         
  7.     Written by:  Mark Cookson
  8.     
  9.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/31/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. #ifndef __READRESOURCE__
  25. #define __READRESOURCE__
  26.  
  27. #include <Errors.h>
  28. #include <Resources.h>
  29.  
  30. #ifndef __DEFINES__
  31. #include "Defines.h"
  32. #endif
  33.  
  34. struct ResourceHeader {
  35.     long            resDataOffset;
  36.     long            resMapOffset;
  37.     long            resDataLength;
  38.     long            resMapLength;
  39. };
  40. typedef struct ResourceHeader ResourceHeader;
  41.  
  42. struct ResourceMap {
  43.     unsigned char    reserved1[16];//for copy of resource header
  44.     long            reserved2;//for handle to next resource map
  45.     short            reserved3;//for file reference number
  46.     short            resFileAttrs;
  47.     unsigned short    typesListOffset;
  48.     unsigned short    namesListOffset;
  49.     unsigned short    numTypesInMap;
  50. };
  51. typedef struct ResourceMap ResourceMap;
  52.  
  53. struct ResourceTypeListEntry {
  54.     OSType            resType;
  55.     unsigned short    numEntries;
  56.     unsigned short    referenceOffset;
  57. };
  58. typedef struct ResourceTypeListEntry ResourceTypeListEntry;
  59.  
  60. struct ResReference {
  61.     short            ID;
  62.     unsigned short    nameOffset;
  63.     long            dataOffset;//high byte is actually resource attributes, low three bytes are offset to beginning of data
  64.     long            reserved;//for handle to resource
  65. };
  66. typedef struct ResReference ResReference;
  67.  
  68.         OSErr    MyGetFirstResource        (short refNum,
  69.                                         OSType targetType,
  70.                                         short *targetID);
  71.  
  72.         OSErr    MyGetResourcePosition    (short refNum,
  73.                                         OSType targetType,
  74.                                         short targetID,
  75.                                         long *firstByte);
  76.         
  77.         OSErr    MyGetTypesPosition        (short refNum,
  78.                                         OSType theType,
  79.                                         short *numResources,
  80.                                         long *dataOffset,
  81.                                         long *firstByteOfTypeList);
  82.  
  83. #endif